#!/bin/bash
API=28
ARCH=arm64
CPU=armv8-a
NDK_PATH=/Users/jimo/Library/Android/sdk/ndk/26.2.11394342/toolchains/llvm/prebuilt/darwin-x86_64
CC=$NDK_PATH/bin/aarch64-linux-android$API-clang
SYSROOT=$NDK_PATH/sysroot
CROSS_PREFIX=$NDK_PATH/bin/llvm-
PREFIX=build/android
rm -rf build
mkdir -p $PREFIX
make clean
export PKG_CONFIG_PATH=/Users/jimo/Desktop/ffmpeg/freetype/install/lib/pkgconfig:/Users/jimo/Downloads/harfbuzz-10.0.1/install/lib/pkgconfig

./configure \
  --prefix=$PREFIX \
  --arch=$ARCH \
  --cpu=$CPU \
  --cross-prefix=$CROSS_PREFIX \
  --enable-cross-compile \
  --sysroot=$SYSROOT \
  --target-os=android \
  --cc=$CC \
  --disable-doc \
  --disable-ffplay \
  --disable-ffprobe \
  --enable-static \
  --disable-shared \
  --disable-everything \
  --disable-filters \
  --disable-swresample \
  --disable-swscale \
  --disable-postproc \
  --disable-w32threads \
  --disable-os2threads \
  --disable-network \
  --disable-dwt \
  --disable-error-resilience \
  --disable-lsp \
  --disable-faan \
  --disable-iamf \
  --disable-pixelutils \
  --disable-avdevice \
  --disable-iconv \
  --disable-zlib \
  --enable-pthreads \
  --enable-avformat \
  --enable-avcodec \
  --enable-avfilter \
  --enable-libfreetype \
  --enable-libharfbuzz \
  --enable-filter=drawtext \
  --extra-cflags="-Os -fpic -march=$CPU -I/Users/jimo/Desktop/ffmpeg/freetype/install/include -I/Users/jimo/Downloads/harfbuzz-10.0.1/install/include" \
  --extra-ldflags="-L/Users/jimo/Desktop/ffmpeg/freetype/install/lib -L/Users/jimo/Downloads/harfbuzz-10.0.1/install/lib" \
  --extra-libs="-lfreetype -lz -lharfbuzz" \
  --pkgconfigdir=/Users/jimo/Desktop/ffmpeg/pkgconfigdir
#make -j8
#make install